<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateFieldsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('fields', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('company_id')->index()->comment('公司ID');
            $table->unsignedInteger('pattern_id')->index()->comment('薪资方案ID');
            $table->string('name')->comment('字段名');
            $table->boolean('salary')->default(0)->comment('薪酬字段');
            $table->boolean('tax')->default(0)->comment('是否缴税');
			$table->timestamps();
			$table->unique(['company_id', 'pattern_id', 'name']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('fields');
    }
}
